package leetcode;

import javax.swing.tree.TreeNode;

public class Solution13 {
    private int Deep = -1;
    private int value = 0;
    public int findBottomLeftValue(TreeNode root) {
        value = root.val;
        findLeftValue(root,0);
        return value;
    }


    public void findLeftValue(TreeNode node,int deep){
        if(node == null){
            return ;
        }
        if(node.left == null && node.right == null){
            if(deep > Deep){
                Deep = deep;
                value = node.val;
            }
        }

        if(node.left != null){
            findLeftValue(node.left,deep + 1);
        }
        if(node.right != null){
            findLeftValue(node.right,deep + 1);
        }
    }
}
